package com.it.you.base.map;

import java.util.*;
import java.util.stream.Collectors;

public class MapTest1 {
    public static void main(String[] args) {
        HashMap<Long, Boolean> map = new HashMap<>();
        if (map.get(4L) == null) {
            System.out.println("直接new的map中4L找不到");
        }

        List<Long> list = new ArrayList<>();
        Map<Long, Boolean> map1 = list.stream().collect(Collectors.toMap(v -> v, s -> true));
        System.out.println(map1);
        if (map1.get(4L) == null) {
            System.out.println("空list通过stream得到的map1中找不到");
        }

        List<Long> list2 = Arrays.asList(1L, 2L, 3L);
        Map<Long, Boolean> map2 = list2.stream().collect(Collectors.toMap(v -> v, s -> true));
        System.out.println(map2);
        if (map2.get(3L) == null) {
            System.out.println("list通过stream得到的map2中找到了");
        }

    }
}
